{% extends base %}

{% block head %}
<style type="text/css">
    pre {
        margin: 0px;
    }
    input[name=input] {
        overflow: inherit;
    }
    input[name=input]:focus {
        outline: none;
        border: 1px solid #8cc;
    }
    .plugin-input {
        width: 200px;
    }
    .output-textarea {
        width: 100%;
        height: 400px;
    }
</style>
<style type="text/css">
    {% raw css_style %}
</style>
{% end %}

{% block body %}
    {% init error       = "" %}
    {% init description = "" %}
    {% init input       = "" %}
    {% init output      = "" %}

    <div class="plugin-head">

        <div class="grid-title">
            {% if model.category %}
                <a class="link2" href="/plugins_list?category={{model.category}}">{{model.category_name}}</a> /
            {% end %}
            
            <span>{{title}}</span>
            <span class="float-right">
                {% if _is_admin and model.editable %}
                    <a href="/code/edit?path={{fpath}}">编辑</a>
                {% end %}
                <a href="javascript:history.back();">返回</a>
            </span>
        </div>

        {% if description != "" %}
            <pre class="col-md-12 info">{{description}}</pre>
        {% end %}

        {% if error != "" %}
            <pre class="col-md-12 error">
            {{error}}
            </pre>
        {% end %}

        {% if rows > 0 %}
        <div class="row">
            <form method="{{method}}">
                <!-- 输入框区域 BEGIN -->
                {% if rows == 1 %}
                    <input type="text" class="plugin-input" name="input" value="{{input}}" placeholder="{{model.placeholder}}"/>
                {% else %}
                    <textarea class="col-md-12 code" name="input" rows={{rows}} placeholder="{{model.placeholder}}">{{input}}</textarea>
                {% end %}
                <!-- 输入框区域 END -->

                <!-- 按钮区域 BEGIN -->
                <button>{{model.btn_text}}</button>
                <!-- 按钮区域 END -->
            </form>
        </div>
        {% end %}
    </div>

    {# HTML输出 #}
    {% if html != None and html != "" %}
        {% raw html %}
    {% end %}

    {# 文本输出放到后面 #}
    {% if output != None and output != "" %}
    <textarea class="output-textarea">{{ output }}</textarea>
    {% end %}

    {% if model.show_pagenation %}
    <div class="card">
        {# 分页 #}
        {% set page = model.page %}
        {% set page_max = model.page_max %}
        {% set page_url = model.page_url %}
        {% include mod_pagenation.html %}
    </div>
    {% end %}
{% end %}

{% block aside %}
    {# 选项 #}
    {% if model.category == "dir" %}
        {% include fs/mod_aside.html %}
    {% elif model.category == "note" %}
        {% include note/component/mod_aside.html %}
    {% elif model.category == "system" %}
        {% include system/mod_aside.html %}
    {% else %}
        {% if len(model.option_links) > 0 %}
            <div class="aside-item">
                <div class="aside-title">
                    选项
                </div>
                <div class="aside-content">
                    {% for link in model.option_links %}
                        <li><a class="link" href="{{link.get('url')}}">{{link.get('name')}}</a></li>
                    {% end %}
                </div>
            </div>
        {% end %}
    {% end %}

    {% raw model.aside_html %}
{% end %}

